<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <meta name="viewport"
          content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="msapplication-config" content="browserconfig.xml" />
    <title>Using the Terraform Docker Provider</title>
    <link rel="apple-touch-icon" sizes="180x180" href="/kitchen-terraform/apple-touch-icon-180x180-precomposed.png">
    <link rel="apple-touch-icon" sizes="152x152" href="/kitchen-terraform/apple-touch-icon-152x152-precomposed.png">
    <link rel="apple-touch-icon" sizes="144x144" href="/kitchen-terraform/apple-touch-icon-144x144-precomposed.png">
    <link rel="apple-touch-icon" sizes="114x114" href="/kitchen-terraform/apple-touch-icon-114x114-precomposed.png">
    <link rel="apple-touch-icon" sizes="72x72" href="/kitchen-terraform/apple-touch-icon-72x72-precomposed.png">
    <link rel="apple-touch-icon" href="/kitchen-terraform/apple-touch-icon-precomposed.png">
    <link rel="icon" type="image/png" sizes="196x196" href="/kitchen-terraform/favicon-196x196.png">
    <link rel="icon" type="image/png" sizes="160x160" href="/kitchen-terraform/favicon-160x160.png">
    <link rel="icon" type="image/png" sizes="96x96" href="/kitchen-terraform/favicon-96x96.png">
    <link rel="icon" type="image/png" sizes="32x32" href="/kitchen-terraform/favicon-32x32.png">
    <link rel="icon" type="image/png" sizes="16x16" href="/kitchen-terraform/favicon-16x16.png">
    <link rel="shortcut icon" href="/kitchen-terraform/favicon.png">
    <link rel="icon" type="image/ico" href="/kitchen-terraform/favicon.ico">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
    <link href="/kitchen-terraform/stylesheets/highlighting.css" rel="stylesheet" />
    <link href="/kitchen-terraform/stylesheets/material.css" rel="stylesheet" />
    <link href="/kitchen-terraform/stylesheets/site.css" rel="stylesheet" />
    <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js" integrity="sha384-vFJXuSJphROIrBnz7yo7oB41mKfc8JzQZiCq4NCceLEaO4IHwicKwpJf9c9IpFgh" crossorigin="anonymous"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js" integrity="sha384-alpBpkh1PFOepccYVYDB4do5UnbKysX5WZXm3XxPqe5iKTfUKjNkCk9SaVuEZflJ" crossorigin="anonymous"></script>
    <script src="/kitchen-terraform/javascripts/site.js"></script>
  </head>
  <body>
    <nav class="navbar fixed-top navbar-expand-lg navbar-light header">
      <img src="/kitchen-terraform/images/kitchen_terraform_logo.png" class="d-inline-block" style="vertical-align: sub; margin-left: 10px;" width="18" height="18" alt="Kitchen-Terraform logo" />
      <a href="/kitchen-terraform/" class="navbar-brand" style="padding-left: 5px;">Kitchen-Terraform</a>
      <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
      </button>
      <div class="collapse navbar-collapse" id="navbarNav">
        <ul class="navbar-nav mr-auto">
          <li class="nav-item">
            <a href="/kitchen-terraform/getting_started.html" class="nav-link">Getting Started</a>
          </li>
          <li class="nav-item">
            <a href="/kitchen-terraform/tutorials/" class="nav-link">Tutorials</a>
          </li>
          <li class="nav-item">
            <a href="/kitchen-terraform/about.html" class="nav-link">About</a>
          </li>
          <li class="nav-item">
            <a href="/kitchen-terraform/community/" class="nav-link">Community</a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="https://github.com/newcontext-oss/kitchen-terraform">
              <img src="/kitchen-terraform/images/github.png" class="d-inline-block" style="vertical-align: sub;" width="18" height="18" alt="GitHub logo" /> Contribute
            </a>
          </li>
        </ul>
      </div>
    </nav>
    <div class="content text-left">
      <div class="container" style="padding-top: 0px;">
  <div class="row">
    <div class="col-12">
      <div class="jumbotron">
        <h1 class="display-3">
          Terraform Docker Provider
        </h1>
        <p class="lead">
          This is an example of how to utilize Kitchen-Terraform to test a Docker container running on localhost configured with the <a href="https://www.terraform.io/docs/providers/docker/index.html" style="color: #32c850;">Terraform Docker Provider</a>.
        </p>
        <div class="float-right">Author: Erik R. Rygg</div>
        <br>
        <div class="float-right">Updated by: Carlos Gutierrez</div>
      </div>
    </div>
  </div>
  <div class="row">
    <div class="col-4">
      <div class="list-group" id="list-tab" role="tablist">
        <a class="list-group-item list-group-item-action active" id="list-one-list" data-toggle="list" href="#list-one" role="tab" aria-controls="one">
          1. Requirements & Setup
        </a>
        <a class="list-group-item list-group-item-action" id="list-two-list" data-toggle="list" href="#list-two" role="tab" aria-controls="two">
          2. Create Terraform code
        </a>
        <a class="list-group-item list-group-item-action" id="list-three-list" data-toggle="list" href="#list-three" role="tab" aria-controls="three">
          3. Create Terraform outputs
        </a>
        <a class="list-group-item list-group-item-action" id="list-four-list" data-toggle="list" href="#list-four" role="tab" aria-controls="four">
          4. Create tests
        </a>
        <a class="list-group-item list-group-item-action" id="list-five-list" data-toggle="list" href="#list-five" role="tab" aria-controls="five">
          5. Run tests
        </a>
      </div>
    </div>
    <div class="col-8">
      <div class="tab-content" id="nav-tabContent">
        <div class="tab-pane fade show active" id="list-one" role="tabpanel" aria-labelledby="list-one-list">
          Requirements are a Docker host listening on the Unix socket located at: unix:///var/run/docker.sock.
          <br><br>
          The Docker container that will be tested must be running an SSH daemon in the foreground to enable the
          Kitchen-Terraform verifier to remotely execute tests.
          <br><hr>
          To setup the project, run the following commands in the terminal:
          <br><br>
<div class="highlight"><pre class="syntax-highlight shell"><code><span class="nb">mkdir</span> <span class="nt">-p</span> docker_provider_example/test/integration/example/controls
<span class="nb">cd </span>docker_provider_example
</code></pre></div>          Create the <p class="font-weight-bold" style="color: #32c850; display: inline;">Gemfile</p> in the root of the project by running:
          <br><br>
          <div class="highlight"><pre class="syntax-highlight shell"><code><span class="nb">touch </span>Gemfile</code></pre></div>
          In this file we will place the dependencies that are required for the project by copying the code below into
          the <p class="font-weight-bold" style="color: #32c850; display: inline;">Gemfile</p>.
          <br><br>
<div class="highlight"><pre class="syntax-highlight ruby"><code><span class="n">source</span> <span class="s1">'https://rubygems.org/'</span> <span class="k">do</span>
  <span class="n">gem</span> <span class="s1">'kitchen-terraform'</span><span class="p">,</span> <span class="s1">'~&gt; 7.0'</span>
<span class="k">end</span>
</code></pre></div>          Next we to install kitchen-terraform and the other rubygems required, we also need to install bundler if it is
          not installed yet, by running the commands below in a terminal in the root of the project:
          <br><br>
<div class="highlight"><pre class="syntax-highlight shell"><code>gem <span class="nb">install </span>bundler
bundle <span class="nb">install</span>
</code></pre></div>          Create a <p class="font-weight-bold" style="color: #32c850; display: inline;">.kitchen.yml</p> file in the root of the project.
          <br><br>
<div class="highlight"><pre class="syntax-highlight shell"><code><span class="nb">touch</span> .kitchen.yml
</code></pre></div>          This file brings together the Terraform module code and Inspec controls. Copy the configuration below into the
          <p class="font-weight-bold" style="color: #32c850; display: inline;">.kitchen.yml</p> file.
          <br><br>
          <div class="row">
            <div class="col">
<div class="highlight"><pre class="syntax-highlight yaml"><code><span class="nn">---</span>
<span class="na">driver</span><span class="pi">:</span>
  <span class="na">name</span><span class="pi">:</span> <span class="s">terraform</span>

<span class="na">provisioner</span><span class="pi">:</span>
  <span class="na">name</span><span class="pi">:</span> <span class="s">terraform</span>

<span class="na">verifier</span><span class="pi">:</span>
  <span class="na">name</span><span class="pi">:</span> <span class="s">terraform</span>
  <span class="na">systems</span><span class="pi">:</span>
    <span class="pi">-</span> <span class="na">name</span><span class="pi">:</span> <span class="s">docker container</span>
      <span class="na">backend</span><span class="pi">:</span> <span class="s">ssh</span>
      <span class="na">password</span><span class="pi">:</span> <span class="s">root</span>
      <span class="na">hosts_output</span><span class="pi">:</span> <span class="s">container_host</span>
      <span class="na">controls</span><span class="pi">:</span>
        <span class="pi">-</span> <span class="s">operating_system</span>
      <span class="na">port</span><span class="pi">:</span> <span class="m">2222</span>
    <span class="pi">-</span> <span class="na">name</span><span class="pi">:</span> <span class="s">localhost</span>
      <span class="na">backend</span><span class="pi">:</span> <span class="s">local</span>
      <span class="na">controls</span><span class="pi">:</span>
        <span class="pi">-</span> <span class="s">state_files</span>

<span class="na">platforms</span><span class="pi">:</span>
  <span class="pi">-</span> <span class="na">name</span><span class="pi">:</span> <span class="s">ubuntu</span>

<span class="na">suites</span><span class="pi">:</span>
  <span class="pi">-</span> <span class="na">name</span><span class="pi">:</span> <span class="s">example</span>

</code></pre></div>            </div>
            <div class="col">
              <br><br>
              The Kitchen-Terraform driver is enabled.
              <br><br><br>
              The Kitchen-Terraform provisioner is enabled.
              <br><br>
              The Kitchen-Terraform verifier is configured with two systems.
              <br><br>
              The Test Kitchen backend is configured to use SSH with password authentication to connect to the Docker container.
              <br><br>
              The container system includes a control for the operating system of the Docker container.
              <br><br>
              For each Docker host (see step 3. Create Terraform outputs), the verifier will run the control over SSH on port 2222.
              <br><br>
              The platforms provide arbitrary grouping for the test suite matrix.
              <br><br>
              The suite name corresponds to the directory containing the Inspec profile: <div class="highlight"><pre class="syntax-highlight shell"><code><span class="nb">test</span>/integration/example/</code></pre></div>
              <br><br>
            </div>
          </div>
        </div>
        <div class="tab-pane fade" id="list-two" role="tabpanel" aria-labelledby="list-two-list">
          Below is the example Terraform code that uses the Docker provider. The resources created by this code is what
          we'll be testing later on.
          <br><br>
          Create the file <p class="font-weight-bold" style="color: #32c850; display: inline;">versions.tf</p> in the root of the project.
          <br><br>
<div class="highlight"><pre class="syntax-highlight shell"><code><span class="nb">touch </span>versions.tf
</code></pre></div>          Add the following block of code into the file.
          <br><br>
          The configuration is restricted to Terraform versions equal to or greater than 0.14.0 and less than 2.0.0. The
          Docker provider is used to interact with Docker containers and images, it uses the Docker API to manage the
          lifecycle of Docker containers.
          <br><br>
<div class="highlight"><pre class="syntax-highlight ruby"><code><span class="c1"># Set the required provider and versions</span>
<span class="n">terraform</span> <span class="p">{</span>
  <span class="n">required_version</span> <span class="o">=</span> <span class="s2">"&gt;= 0.14.0, &lt; 2.0.0"</span>

  <span class="n">required_providers</span> <span class="p">{</span>
  <span class="c1"># We recommend pinning to the specific version of the Docker Provider you're using</span>
  <span class="c1"># since new versions are released frequently</span>
    <span class="n">docker</span> <span class="o">=</span> <span class="p">{</span>
      <span class="n">source</span> <span class="o">=</span> <span class="s2">"kreuzwerker/docker"</span>
      <span class="n">version</span> <span class="o">=</span> <span class="s2">"2.23.1"</span>
      <span class="p">}</span>
    <span class="p">}</span>
  <span class="p">}</span>
</code></pre></div>          Create the file <p class="font-weight-bold" style="color: #32c850; display: inline;">main.tf</p> in the root of the project.
          <br><br>
<div class="highlight"><pre class="syntax-highlight shell"><code><span class="nb">touch </span>main.tf
</code></pre></div>          Add each of the following blocks of code into the file.
          <br><br>
          The Docker provider is configured to communicate with a Docker host listening on a Unix socket.
          <br><br>
<div class="highlight"><pre class="syntax-highlight ruby"><code><span class="n">provider</span> <span class="s2">"docker"</span> <span class="p">{</span>
  <span class="n">host</span> <span class="o">=</span> <span class="s2">"unix:///var/run/docker.sock"</span>
<span class="p">}</span>
</code></pre></div>          A SSH daemon Docker image from the public registry is configured as a data source.
          <br><br>
<div class="highlight"><pre class="syntax-highlight ruby"><code><span class="n">data</span> <span class="s2">"docker_registry_image"</span> <span class="s2">"ubuntu_sshd"</span> <span class="p">{</span>
  <span class="nb">name</span> <span class="o">=</span> <span class="s2">"rastasheep/ubuntu-sshd:latest"</span>
<span class="p">}</span>
</code></pre></div>          A Docker image is configured on the Docker host using the data source.
          <br><br>
<div class="highlight"><pre class="syntax-highlight ruby"><code><span class="n">resource</span> <span class="s2">"docker_image"</span> <span class="s2">"ubuntu_sshd"</span> <span class="p">{</span>
  <span class="n">keep_locally</span> <span class="o">=</span> <span class="kp">true</span>
  <span class="nb">name</span> <span class="o">=</span> <span class="n">data</span><span class="p">.</span><span class="nf">docker_registry_image</span><span class="p">.</span><span class="nf">ubuntu_sshd</span><span class="p">.</span><span class="nf">name</span>
  <span class="n">pull_triggers</span> <span class="o">=</span> <span class="p">[</span><span class="n">data</span><span class="p">.</span><span class="nf">docker_registry_image</span><span class="p">.</span><span class="nf">ubuntu_sshd</span><span class="p">.</span><span class="nf">sha256_digest</span><span class="p">]</span>
<span class="p">}</span>
</code></pre></div>          A Docker container based on the Docker image is configured to be running on the Docker host. The container
          forwards localhost:2222 to its internal SSH daemon.
          <br><br>
<div class="highlight"><pre class="syntax-highlight ruby"><code><span class="n">resource</span> <span class="s2">"docker_container"</span> <span class="s2">"ubuntu"</span> <span class="p">{</span>
  <span class="n">image</span> <span class="o">=</span> <span class="n">docker_image</span><span class="p">.</span><span class="nf">ubuntu_sshd</span><span class="p">.</span><span class="nf">latest</span>
  <span class="n">must_run</span> <span class="o">=</span> <span class="kp">true</span>
  <span class="nb">name</span> <span class="o">=</span> <span class="s2">"ubuntu_container"</span>

  <span class="n">ports</span> <span class="p">{</span>
    <span class="n">external</span> <span class="o">=</span> <span class="mi">2222</span>
    <span class="n">internal</span> <span class="o">=</span> <span class="mi">22</span>
  <span class="p">}</span>
<span class="p">}</span>

</code></pre></div>        </div>
        <div class="tab-pane fade" id="list-three" role="tabpanel" aria-labelledby="list-three-list">
          To assist with testing, Terraform outputs will provide the path of the backend state file and the container
          host name. The Kitchen-Terraform verifier can use these artifacts to validate the Terraform code.
          <br><br>
          Create the file <p class="font-weight-bold" style="color: #32c850; display: inline;">output.tf</p>
          <br><br>
<div class="highlight"><pre class="syntax-highlight shell"><code><span class="nb">touch </span>output.tf
</code></pre></div>          Add each block of code into the file.
          <br><br>
<div class="highlight"><pre class="syntax-highlight ruby"><code><span class="n">output</span> <span class="s2">"terraform state"</span> <span class="p">{</span>
  <span class="n">description</span> <span class="o">=</span> <span class="s2">"The path to the backend state file"</span>
  <span class="n">value</span> <span class="o">=</span> <span class="s2">"${path.module}/terraform.tfstate.d/${terraform.workspace}/terraform.tfstate"</span>
<span class="p">}</span>

<span class="n">output</span> <span class="s2">"container_host"</span> <span class="p">{</span>
  <span class="n">description</span> <span class="o">=</span> <span class="s2">"The container's host name"</span>
  <span class="n">value</span> <span class="o">=</span> <span class="s2">"localhost"</span>
<span class="p">}</span>
</code></pre></div>          Refer back to the <p class="font-weight-bold" style="color: #32c850; display: inline;">.kitchen.yml</p> file and in the verifier section
          you will see a reference to the above container host output.
          <br><br>
        </div>
        <div class="tab-pane fade" id="list-four" role="tabpanel" aria-labelledby="list-four-list">
          We've created the Terraform code, now it's time to create the Inspec control tests. Please see the <a href="https://www.inspec.io/docs/reference/profiles/" style="color: #32c850;">Inspec documentation</a> to learn more about profiles and controls.
          <br><br>
          Create a default profile file <p class="font-weight-bold" style="color: #32c850; display: inline;">test/integration/example/inspec.yml</p>
          <br><br>
<div class="highlight"><pre class="syntax-highlight shell"><code><span class="nb">touch test</span>/integration/examples/inspec.yml
</code></pre></div>          Add the block below into the file.
          <br><br>
<div class="highlight"><pre class="syntax-highlight yaml"><code><span class="nn">---</span>
<span class="na">name</span><span class="pi">:</span> <span class="s">default</span>
</code></pre></div>          Referring back to the <p class="font-weight-bold" style="color: #32c850; display: inline;">.kitchen.yml</p> file and inside the verifier section there is an operating_system control which we need to create.
          <br><br>
          Create the file <p class="font-weight-bold" style="color: #32c850; display: inline;">test/integration/example/controls/operating_system.rb</p>
<div class="highlight"><pre class="syntax-highlight ruby"><code><span class="c1"># frozen_string_literal: true</span>

<span class="n">control</span> <span class="s1">'operating_system'</span> <span class="k">do</span>
  <span class="n">describe</span> <span class="n">command</span><span class="p">(</span><span class="s2">"lsb_release -a"</span><span class="p">)</span> <span class="k">do</span>
    <span class="n">its</span><span class="p">(</span><span class="s1">'stderr'</span><span class="p">)</span> <span class="p">{</span> <span class="n">should</span> <span class="n">match</span> <span class="sr">/lsb_release: command not found/</span> <span class="p">}</span>
  <span class="k">end</span>

  <span class="n">describe</span> <span class="n">command</span><span class="p">(</span><span class="s1">'uname -ar'</span><span class="p">)</span> <span class="k">do</span>
    <span class="n">its</span><span class="p">(</span><span class="s1">'stdout'</span><span class="p">)</span> <span class="p">{</span> <span class="n">should</span> <span class="n">match</span><span class="p">(</span><span class="sr">/Linux/</span><span class="p">)</span> <span class="p">}</span>
  <span class="k">end</span>

  <span class="n">describe</span> <span class="n">command</span><span class="p">(</span><span class="s2">"env -i bash -c '. /etc/os-release; echo $NAME'"</span><span class="p">)</span> <span class="k">do</span>
    <span class="n">its</span><span class="p">(</span><span class="s1">'stdout'</span><span class="p">)</span> <span class="p">{</span> <span class="n">should</span> <span class="n">match</span> <span class="sr">/Ubuntu/</span> <span class="p">}</span>
  <span class="k">end</span>
<span class="k">end</span>
</code></pre></div>          Let's create the state_files control, which will validate the Terraform state file is created and has the proper content.
          <br><br>
          Create the file <p class="font-weight-bold" style="color: #32c850; display: inline;">test/integration/example/controls/state_file.rb</p>
<div class="highlight"><pre class="syntax-highlight ruby"><code><span class="c1"># frozen_string_literal: true</span>

<span class="n">terraform_state</span> <span class="o">=</span> <span class="n">input</span><span class="p">(</span><span class="s1">'terraform_state'</span><span class="p">,</span> <span class="p">{})</span>

<span class="n">control</span> <span class="s1">'state_files'</span> <span class="k">do</span>
  <span class="n">describe</span> <span class="s1">'the terraform state file'</span> <span class="k">do</span>
    <span class="n">subject</span> <span class="k">do</span>
      <span class="n">file</span> <span class="n">terraform_state</span>
    <span class="k">end</span>

    <span class="n">it</span> <span class="k">do</span>
      <span class="n">is_expected</span><span class="p">.</span><span class="nf">to</span> <span class="n">exist</span>
    <span class="k">end</span>
  <span class="k">end</span>
<span class="k">end</span>
</code></pre></div>          <br><br>
        </div>
        <div class="tab-pane fade" id="list-five" role="tabpanel" aria-labelledby="list-five-list">
          <strong>Before commencing this section of the tutorial please ensure docker is running on your machine, failure to do
          will mean that you will not be able to successfully run the commands.</strong>
          <br><br>
          Execute Kitchen-Terraform by running the command below in the terminal:
          <br><br>
<div class="highlight"><pre class="syntax-highlight ruby"><code><span class="n">bundle</span> <span class="nb">exec</span> <span class="n">kitchen</span> <span class="n">converge</span>
</code></pre></div>          This creates resources from the Terraform code in the main.tf file. Below is an example output of
          Kitchen-Terraform running when you use the <strong>converge</strong> command.
          <br><br>
<div class="highlight"><pre class="syntax-highlight shell"><code><span class="nt">-----</span><span class="o">&gt;</span> Starting Test Kitchen <span class="o">(</span>v3.4.0<span class="o">)</span>
<span class="nt">-----</span><span class="o">&gt;</span> Creating &lt;example-ubuntu&gt;...
<span class="nv">$$$$$$</span> Reading the Terraform client version...
       Terraform v0.14.0
       + provider registry.terraform.io/kreuzwerker/docker v2.23.1

       Your version of Terraform is out of <span class="nb">date</span><span class="o">!</span> The latest version
       is 1.3.6. You can update by downloading from https://www.terraform.io/downloads.html
<span class="nv">$$$$$$</span> Finished reading the Terraform client version.
<span class="nv">$$$$$$</span> Verifying the Terraform client version is <span class="k">in </span>the supported interval of <span class="o">&gt;=</span> 0.11.4, &lt; 2.0.0...
<span class="nv">$$$$$$</span> Finished verifying the Terraform client version.
<span class="nv">$$$$$$</span> Initializing the Terraform working directory...

       Initializing the backend...

       Initializing provider plugins...
       - Finding kreuzwerker/docker versions matching <span class="s2">"2.23.1"</span>...
       - Installing kreuzwerker/docker v2.23.1...
       - Installed kreuzwerker/docker v2.23.1 <span class="o">(</span>self-signed, key ID BD080C4571C6104C<span class="o">)</span>

       Partner and community providers are signed by their developers.
       If you<span class="s1">'d like to know more about provider signing, you can read about it here:
       https://www.terraform.io/docs/plugins/signing.html

       Terraform has been successfully initialized!
$$$$$$ Finished initializing the Terraform working directory.
$$$$$$ Creating the kitchen-terraform-example-ubuntu Terraform workspace...
       Created and switched to workspace "kitchen-terraform-example-ubuntu"!

       You'</span>re now on a new, empty workspace. Workspaces isolate their state,
       so <span class="k">if </span>you run <span class="s2">"terraform plan"</span> Terraform will not see any existing state
       <span class="k">for </span>this configuration.
<span class="nv">$$$$$$</span> Finished creating the kitchen-terraform-example-ubuntu Terraform workspace.
       Finished creating &lt;example-ubuntu&gt; <span class="o">(</span>0m3.36s<span class="o">)</span><span class="nb">.</span>
<span class="nt">-----</span><span class="o">&gt;</span> Converging &lt;example-ubuntu&gt;...
<span class="nv">$$$$$$</span> Reading the Terraform client version...
       Terraform v0.14.0
       + provider registry.terraform.io/kreuzwerker/docker v2.23.1

       Your version of Terraform is out of <span class="nb">date</span><span class="o">!</span> The latest version
       is 1.3.6. You can update by downloading from https://www.terraform.io/downloads.html
<span class="nv">$$$$$$</span> Finished reading the Terraform client version.
<span class="nv">$$$$$$</span> Verifying the Terraform client version is <span class="k">in </span>the supported interval of <span class="o">&gt;=</span> 0.11.4, &lt; 2.0.0...
<span class="nv">$$$$$$</span> Finished verifying the Terraform client version.
<span class="nv">$$$$$$</span> Selecting the kitchen-terraform-example-ubuntu Terraform workspace...
<span class="nv">$$$$$$</span> Finished selecting the kitchen-terraform-example-ubuntu Terraform workspace.
<span class="nv">$$$$$$</span> Downloading the modules needed <span class="k">for </span>the Terraform configuration...
<span class="nv">$$$$$$</span> Finished downloading the modules needed <span class="k">for </span>the Terraform configuration.
<span class="nv">$$$$$$</span> Validating the Terraform configuration files...
       Success! The configuration is valid.

<span class="nv">$$$$$$</span> Finished validating the Terraform configuration files.
<span class="nv">$$$$$$</span> Building the infrastructure based on the Terraform configuration...
       docker_image.ubuntu_sshd: Creating...
       docker_image.ubuntu_sshd: Creation <span class="nb">complete </span>after 0s <span class="o">[</span><span class="nb">id</span><span class="o">=</span>sha256:49533628fb371c9f1952c06cedf912c78a81fbe3914901334673c369376e077erastasheep/ubuntu-sshd:latest]
       docker_container.ubuntu: Creating...
       docker_container.ubuntu: Creation <span class="nb">complete </span>after 1s <span class="o">[</span><span class="nb">id</span><span class="o">=</span>b2766cde74c528e46638f5ab273476431402f7053668499145bc03a12e07291f]

       Apply <span class="nb">complete</span><span class="o">!</span> Resources: 2 added, 0 changed, 0 destroyed.

       Outputs:

       container_host <span class="o">=</span> <span class="s2">"localhost"</span>
       terraform_state <span class="o">=</span> <span class="s2">"./terraform.tfstate.d/kitchen-terraform-example-ubuntu/terraform.tfstate"</span>
<span class="nv">$$$$$$</span> Finished building the infrastructure based on the Terraform configuration.
<span class="nv">$$$$$$</span> Reading the output variables from the Terraform state...
<span class="nv">$$$$$$</span> Finished reading the output variables from the Terraform state.
<span class="nv">$$$$$$</span> Parsing the Terraform output variables as JSON...
<span class="nv">$$$$$$</span> Finished parsing the Terraform output variables as JSON.
<span class="nv">$$$$$$</span> Writing the output variables to the Kitchen instance state...
<span class="nv">$$$$$$</span> Finished writing the output variables to the Kitchen instance state.
<span class="nv">$$$$$$</span> Writing the input variables to the Kitchen instance state...
<span class="nv">$$$$$$</span> Finished writing the input variables to the Kitchen instance state.
       Finished converging &lt;example-ubuntu&gt; <span class="o">(</span>0m3.32s<span class="o">)</span><span class="nb">.</span>
<span class="nt">-----</span><span class="o">&gt;</span> Test Kitchen is finished. <span class="o">(</span>0m7.86s<span class="o">)</span>

</code></pre></div>
Now run the Kitchen-Terraform tests using:
          <br><br>
<div class="highlight"><pre class="syntax-highlight ruby"><code><span class="n">bundle</span> <span class="nb">exec</span> <span class="n">kitchen</span> <span class="n">verify</span>
</code></pre></div>          This executes the Inspec controls from the .kitchen.yml verifier section and will run the tests in the
          <strong>operating_system.rb</strong> and <strong>state_file.rb</strong> files.
          The output below is an example of Kitchen-Terraform running when you use the <strong>verify</strong> command.
        <br><br>
<div class="highlight"><pre class="syntax-highlight shell"><code><span class="nt">-----</span><span class="o">&gt;</span> Starting Test Kitchen <span class="o">(</span>v3.4.0<span class="o">)</span>
<span class="nt">-----</span><span class="o">&gt;</span> Setting up &lt;example-ubuntu&gt;...
       Finished setting up &lt;example-ubuntu&gt; <span class="o">(</span>0m0.00s<span class="o">)</span><span class="nb">.</span>
<span class="nt">-----</span><span class="o">&gt;</span> Verifying &lt;example-ubuntu&gt;...
<span class="nv">$$$$$$</span> Reading the Terraform input variables from the Kitchen instance state...
<span class="nv">$$$$$$</span> Finished reading the Terraform input variables from the Kitchen instance state.
<span class="nv">$$$$$$</span> Reading the Terraform output variables from the Kitchen instance state...
<span class="nv">$$$$$$</span> Finished reading the Terraform output variables from the Kitchen instance state.
<span class="nv">$$$$$$</span> Verifying the systems...
<span class="nv">$$$$$$</span> Verifying the <span class="s1">'docker container'</span> system...

       Profile: default
       Version: <span class="o">(</span>not specified<span class="o">)</span>
       Target:  ssh://root@localhost:2222

       ✔  operating_system: Command: <span class="sb">`</span>lsb_release <span class="nt">-a</span><span class="sb">`</span>
           ✔  Command: <span class="sb">`</span>lsb_release <span class="nt">-a</span><span class="sb">`</span> stderr is expected to match /lsb_release: <span class="nb">command </span>not found/
           ✔  Command: <span class="sb">`</span><span class="nb">uname</span> <span class="nt">-ar</span><span class="sb">`</span> stdout is expected to match /Linux/
           ✔  Command: <span class="sb">`</span><span class="nb">env</span> <span class="nt">-i</span> bash <span class="nt">-c</span> <span class="s1">'. /etc/os-release; echo $NAME'</span><span class="sb">`</span> stdout is expected to match /Ubuntu/


       Profile Summary: 1 successful control, 0 control failures, 0 controls skipped
       Test Summary: 3 successful, 0 failures, 0 skipped
<span class="nv">$$$$$$</span> Finished verifying the <span class="s1">'docker container'</span> system.
<span class="nv">$$$$$$</span> Verifying the <span class="s1">'terraform state'</span> system...

       Profile: default
       Version: <span class="o">(</span>not specified<span class="o">)</span>
       Target:  <span class="nb">local</span>://

       ✔  state_files: the terraform state file
           ✔  the terraform state file is expected to exist


       Profile Summary: 1 successful control, 0 control failures, 0 controls skipped
       Test Summary: 1 successful, 0 failures, 0 skipped
<span class="nv">$$$$$$</span> Finished verifying the <span class="s1">'terraform state'</span> system.
<span class="nv">$$$$$$</span> Finished verifying the systems.
       Finished verifying &lt;example-ubuntu&gt; <span class="o">(</span>0m6.20s<span class="o">)</span><span class="nb">.</span>
<span class="nt">-----</span><span class="o">&gt;</span> Test Kitchen is finished. <span class="o">(</span>0m7.62s<span class="o">)</span>
</code></pre></div>          Once you are finished running the tests with:
          <br><br>
<div class="highlight"><pre class="syntax-highlight ruby"><code><span class="n">bundle</span> <span class="nb">exec</span> <span class="n">kitchen</span> <span class="n">verify</span>
</code></pre></div>          Run the following in the terminal:
          <br><br>
<div class="highlight"><pre class="syntax-highlight shell"><code>bundle <span class="nb">exec </span>kitchen destroy
</code></pre></div>          This will destroy the docker container and delete all information for that instance.
          <br><br>
      </div>
    </div>
  </div>
</div>
</div>

    </div>
    <footer class="footer">
      <div class="container">
        <span class="text-muted">Community driven, created and maintained by
          <a href="http://copado.com" style="color: #32c850;">
            <img src="/kitchen-terraform/images/copado_logo.png" class="d-inline-block" style="vertical-align: sub;" width="30" height="24" alt="Copado NCS LLC logo" />
            Copado NCS LLC
          </a>
        </span>
      </div>
    </footer>
  </body>
</html>
